package com.controller;

import com.dto.excution.TeacherExcution;
import com.dto.in.AddTeacherDto;
import com.entity.Teacher;
import com.enums.TeacherEnum;
import com.service.TeacherService;
import com.util.UUIDUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

/**
 * Created by Administrator on 2018/10/16.
 */
@RestController
@RequestMapping("teacher")
public class SelectTeacherController {
    @Autowired
    private TeacherService teacherServer;

    @ApiOperation(value = "获取教师列表")
    @PostMapping(value = "/choseTeacher")
    @ResponseBody
    public TeacherExcution<List<Teacher>> choseteacher(Integer limit, Integer cityId, Integer subjectId, Integer areaId) {
        List<Teacher> teacher = teacherServer.choseTeacher(limit, cityId, subjectId, areaId);
        if (teacher != null)
            return new TeacherExcution<List<Teacher>>(teacher, TeacherEnum.SUCCESS);
        else return new TeacherExcution<List<Teacher>>(teacher, TeacherEnum.FAIL);
    }

    @ApiOperation(value = "查找教师")
    @PostMapping(value = "/selectTeacher")
    @ResponseBody
    public TeacherExcution<Teacher> selectTeacher(String userId) {
        Teacher teacher = teacherServer.selectTeacher(userId);
        System.out.println(teacher);
        if (teacher != null)
            return new TeacherExcution<Teacher>(teacher, TeacherEnum.SUCCESS);
        else return new TeacherExcution<Teacher>(teacher, TeacherEnum.FAIL);
    }

    @ApiOperation(value = "隐藏简历")
    @PostMapping(value = "/updateResumeStatus")
    @ResponseBody
    public TeacherExcution<Void> updateResumeStatus(Integer userId, Boolean checked) {
        int teacher = teacherServer.updateResumeStatus(userId, checked);
        if (teacher > 0) {
            return new TeacherExcution<Void>(null, TeacherEnum.SUCCESS);
        } else {
            return new TeacherExcution<Void>(null, TeacherEnum.FAIL);
        }
    }

    @ApiOperation(value = "添加老师信息")
    @PostMapping(value = "/addTeacher")
    @ResponseBody
    public TeacherExcution<Void> addStudent(AddTeacherDto addTeacherDto) {
        int success = teacherServer.addTeacher(addTeacherDto);
        if (success > 0) {
            return new TeacherExcution<Void>(null, TeacherEnum.SUCCESS);
        } else {
            return new TeacherExcution<Void>(null, TeacherEnum.FAIL);
        }
    }

    @ApiOperation(value = "查询教师名师值")
    @PostMapping(value = "/findTeacherValue")
    @ResponseBody
    public TeacherExcution findTeacherValue(Integer userId) {
        int success = teacherServer.findTeacherValue(userId);
        if (success > 0) {
            return new TeacherExcution(success, TeacherEnum.SUCCESS);
        } else {
            return new TeacherExcution(success, TeacherEnum.FAIL);
        }
    }

}
